import request from "../request";

const controller = "GalGame";

export const getGalInfo_API = (data) => {
    return request.get(`${controller}/getGalInfo?${queryStr(data)}`);
};

export const getGalList_API = (data) => {
    return request.get(`${controller}/getGalList?${queryStr(data)}`);
};

export const getGalListOfSelect_API = (data) => {
    return request.get(`${controller}/getGalListOfSelect?${queryStr(data)}`);
};

export const getGalTagList_API = () => {
    return request.get(`${controller}/getGalTagList`);
};

export const getGalTagListOfType_API = (data) => {
    return request.get(`${controller}/getGalTagListOfType?${queryStr(data)}`);
};

export const addGalTag_API = (data) => {
    return request.post(`${controller}/addGalTag`, queryStr(data));
};

export const addGalDownloadCount_API = (data) => {
    return request.post(`${controller}/addGalDownloadCount`, queryStr(data));
};

export const getfilePath_API = (data) => {
    return request.get(`${controller}/getfilePath?${queryStr(data)}`);
};

export const getGalOfTop_API = (data) => {
    return request.get(`${controller}/getGalOfTop`);
};

const queryStr = (data) => {
    let str = "";
    for (var key in data) {
        str += `${key}=${data[key]}&`;
    }
    if (str[str.length - 1] == "&") {
        str = str.substring(0, str.length - 1);
    }
    return str;
};
